<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">

    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="审核拒绝原因">
          <a-textarea placeholder="请输入审核拒绝原因" v-model="auditDesc" :autosize="{ minRows: 6, maxRows: 9 }"/>
        </a-form-item>

      </a-form>
    </a-spin>
  </a-modal>
</template>
<script>
  import { deleteAction } from '@/api/manage'

  export default {
    name: "fpAuditForm",
    data () {
      return {
        title:"操作",
        visible: false,
        id:"",
        auditDesc:"",
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        form: this.$form.createForm(this),
        unAuditUrl:"/product/faProduct/unAudit",
      }
    },
    created () {
    },
    methods: {
      unAudit (id) {
        this.id = id;
        this.auditDesc = "";
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        if(that.auditDesc == ""){
          that.$message.warning("请输入驳回原因！");
          return;
        }
        deleteAction(that.unAuditUrl, {id: that.id,auditDesc:that.auditDesc}).then((res) => {
          if(res.success){
            that.$message.success(res.message);
            that.$emit('ok');
            this.visible = false;
          }else{
            that.$message.warning(res.message);
          }
        }).finally(() => {
          that.confirmLoading = false;
        });
      },
      handleCancel () {
        this.close()
      },
    }
  }
</script>